package cn.wolfcode.service.impl;

import cn.wolfcode.domain.LogInfo;
import cn.wolfcode.mapper.LogInfoMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ILogInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogInfoServiceImpl implements ILogInfoService {

    @Autowired
    private LogInfoMapper logInfoMapper;


    @Override
    public void save(LogInfo logInfo) {
        logInfoMapper.insert(logInfo);
    }

    @Override
    public void delete(Long id) {
        logInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public LogInfo get(Long id) {
        return logInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<LogInfo> listAll() {
        return logInfoMapper.selectAll();
    }

    @Override
    public PageInfo<LogInfo> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<LogInfo> logInfos = logInfoMapper.query(qo);
        return new PageInfo<>(logInfos);
    }

}
